package de.obs.mvl.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;

import de.obs.mvl.xml.XMLCreatorVector_2;
import de.obs.mvl.xml.Xml2html;

public class Window_ActionListener implements ActionListener{
	private String ac;
	private Window_Contents content;
	
	public Window_ActionListener(){
		ac = "";
	}

	public void actionPerformed(ActionEvent e) {
		ac = e.getActionCommand();
		content = Window_Contents.getContent();
		
		if(ac.equals("xml_create")){
			
			XMLCreatorVector_2.main(null);
			content.getBtn_html_create().setEnabled(true);
			content.getLbl_bottom_status().setText("XML Created");
			
		}else if (ac.equals("html_create")){
			//Create HTML with the afore created xml as source
			//String[] start = new String[2];
			//start[0] = "data_new2.xml";
			//start[1] = "output.html";
			try {
				Xml2html.main(null);
				content.getLbl_bottom_status().setText("HTML Created");
			} catch (TransformerConfigurationException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (FileNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (TransformerException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			
		}else if (ac.equals("Close")){
			System.exit(0);
		}
		
	}

}
